package com.njym.java.security.app.biz;

import com.github.pagehelper.PageHelper;
import com.njym.java.annotation.Cache;
import com.njym.java.annotation.CacheClear;
import com.njym.java.security.app.entity.FamilyUser;
import com.njym.java.security.app.entity.FamilyUserVo;
import com.njym.java.security.app.mapper.FamilyUserMapper;
import com.njym.java.security.common.biz.BaseBiz;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 
 *
 * @author lijie
 * @email 717057076@qq.com
 * @date 2019-11-13 13:34:39
 */
@Service
public class FamilyUserBiz extends BaseBiz<FamilyUserMapper,FamilyUser> {
    @Resource
    private FamilyUserMapper familyUserMapper;

    /**
     * 根据用户名获取用户信息
     * @param mobile
     * @return
     */
    @Cache(key="appuser{1}" )
    public FamilyUser getUserByMobile(String mobile){
        FamilyUser user = new FamilyUser();
        user.setMobile(mobile);
        return mapper.selectOne(user);
    }
    @CacheClear(key="appuser{1}")
    public void deluser( String mobile) {
    }

    public FamilyUser getUserInfo(String mobile){
        return  familyUserMapper.userInfo(mobile);
    }
    public FamilyUser all(String mobile){
        return  familyUserMapper.all(mobile);
    }


    public int  insertFamily(FamilyUser familyUser) {
        return  familyUserMapper.insert(familyUser);
    }

    public int insertFamilyUser(FamilyUser familyUser) {
        return  familyUserMapper.insertFamilyUser(familyUser);
    }

    public void updateUserPoints(Integer userId, Integer point) {
        mapper.updateUserPoints(userId, point);
    }

    public Integer getDailiCounts(String name) {
        return mapper.getDailiCounts(name);
    }

    public Integer getAllUserCounts() {
        return mapper.getAllUserCounts();
    }

    public Integer getDailiUserCounts() {
        return mapper.getDailiUserCounts();
    }

    public List<FamilyUserVo> queryDaiLiRegister(Integer page, Integer limit, String name) {
        int index = page*limit;
        return mapper.queryDaiLiRegister(index,limit,name);
    }

    public Integer countHasPay(String generalizeCode) {
        return mapper.countHasPay(generalizeCode);
    }

    public long countHasPay_2(String baseId, String fuserId) {
        return mapper.countHasPay_2(baseId,fuserId);
    }

    public long getTotal(String generalizeCode, Integer ids) {
        return mapper.getTotal(generalizeCode, ids);
    }

    public long getTotal_2(String baseId, Integer ids, String generalizeCode) {
        return mapper.getTotal_2(baseId, ids, generalizeCode);
    }

    public long getTotalPopular(Integer ids, String baseId) {
        return mapper.getTotalPopular(ids, baseId);
    }


    public List<FamilyUserVo> queryDaiLiUser(String fuserId, Integer id, String mobile, String start, String end, Integer page, Integer limit, Integer order, Integer isPay){
        PageHelper.startPage(page, limit);
        return mapper.queryDaiLiUser(fuserId, id, mobile, start, end, order, isPay);
    }

    public List<FamilyUserVo> queryDaiLi(String fuserId, Integer id, String baseId, String mobile, String start, String end, Integer page, Integer limit, Integer order, Integer isPay){
        PageHelper.startPage(page, limit);
        return mapper.queryDaiLi(fuserId, id, baseId, mobile, start, end, order, isPay);
    }
}